package com.webonn.frame.util;

import java.util.List;

/**
 * Created by Administrator on 2016/11/19.
 */
public class MyStringUtil {

    public static String listToSqlTerm(List<String> items){
        if(items == null || items.size() < 1){
            return " (null) ";
        }
        StringBuffer sb = new StringBuffer(" ('"+items.get(0).toString()+"'");
        if(items.size() > 1)
            for(int i =1 ; i < items.size(); i++){
                sb.append(",'"+items.get(i).toString()+"'");
            }
        sb.append(")");
        return sb.toString();
    }

    public static boolean nonNullOrEmpty(String toTest) {
        return toTest != null && toTest.trim().length() != 0;
    }

    public static boolean isNullOrEmpty(String toTest) {
        return toTest == null || toTest.trim().length() == 0;
    }

    public static boolean isEmptyOrWhitespaceOnly(String str) {
        if(str != null && str.length() > 0) {
            return str.trim().length() < 1 ;
        } else {
            return true;
        }
    }


}
